<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="box" style="height: 100px;width: 100px; background-color: red"></div>
  <button id="addBtn">事件绑定</button>
  <button id="removeBtn">事件移除</button>
  <script>
    const oBox = document.getElementById('box');
    const oAddBtn = document.getElementById('addBtn');
    const oRemoveBtn = document.getElementById('removeBtn');
    function hanler(e) {
      console.log(e)
    }
    oAddBtn.onclick = function () {
      oBox.addEventListener('click', hanler, false)
    }
    oRemoveBtn.onclick = function () {
      oBox.removeEventListener('click', hanler, false)
    }
  </script>
</body>

</html>